<?php
/**
 * Created by PhpStorm.
 * User: zhanghaisheng
 * Date: 2016/11/3
 * Time: 17:55
 */


 

//参数
$name = $_POST['name'];
$desc = $_POST['desc'];
$start = $_POST['start'];
$min = $_POST['min'];
$last = $_POST['last'];
$gold = $_POST['gold'];
$own = $_POST['own'];
$tick = $_POST['tick'];

//图
$uploads_dir = 'icons/';
if ($_FILES["icon"]["error"] == UPLOAD_ERR_OK) {
    $tmp_name = $_FILES["icon"]["tmp_name"];
    //$name = $_FILES["userfile"]["name"];
    $iconame=$_FILES['icon']['name'];
    move_uploaded_file($tmp_name, $uploads_dir.$iconame);
}else{
    echo "缺少参数";return;
}


//
$redis = new \Redis();
$redis->connect('127.0.0.1',6379);
//id
$id = $redis->incr('id');

//存储赛季 season 数据

$season = array(
    'name'=>$name,
    'desc'=>$desc,
    'start'=>$start,
    'min'=>$min,
    'last'=>$last,
    'gold'=>$gold,
    'icon'=>$_SERVER['HTTP_HOST'].'/icons/'.$iconame,
    'tick'=>$tick,
    'own'=>$own,
    'id'=>'season:'.$id
);



$pipeline = $redis->multi();
$pipeline->hMSet('season:'.$id, $season);
$pipeline->hMSet('cre_saiji|'.$id, $season);


// 顺序
$pipeline->zIncrBy('seasons',time(),'season:'.$id);
$seasonIdS = $pipeline->exec();

header("Location: index.html");


